import 'package:custompaint/bean/FakeWidget.dart';
import 'package:custompaint/bean/OutputBean.dart';
import 'package:get/get.dart';

class TabBean {
  final RxList<FakeWidget> list;
  final String animationsName;

  TabBean({required this.list, required this.animationsName});

  Map<String, dynamic> toJson() {
    return {
      "animationsName": animationsName,
      "list": list.map((element) => element.toJson()).toList(),
    };
  }

  OutputFrame toFrame() {
    return OutputFrame(
        animationsName: animationsName,
        list: list.map((element) => element.toOutputBean()).toList());
  }

  static TabBean fromJson(dynamic json) {
    var l = json['list'];
    RxList<FakeWidget> list = <FakeWidget>[].obs;
    if (l is List) {
      list.value = l.map((e) => FakeWidget.fromJson(e)).toList();
    } else {
      list.value = [];
    }
    return TabBean(list: list, animationsName: json['animationsName']);
  }
}
